<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title> 复选框应用 </title>
		<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
	</head>
	<body>
		
		<form action="chekBox.html" method="get">
			<input type="checkbox" id="checkAll" />全选 
			
			<br/>

  
			<input type="checkbox" name="items"  value="足球" />足球
			<input type="checkbox" name="items"  value="篮球" />篮球
			<label><input type="checkbox" name="items"  value="羽毛球" />羽毛球</label>
			<label><input type="checkbox" name="items"  value="乒乓球" />乒乓球</label>
		
			<input type="button" id="btnSubmit" value="提交"/>
		</form>
		
	</body>
	
	<script type="text/javascript">
		$('#checkAll').click(function(){
			console.log(111, this.checked, $('[name=items]:checkbox'))
			$('[name=items]:checkbox').attr('checked', this.checked)
		})
		
		$('#btnSubmit').click(function(){
			var str = '你喜欢的运动是: \r\n'
			$('[name=items]:checkbox:checked').each(function(){
				str += $(this).val() +'\r\n'
			})
			alert(str)
		})
	
	</script>
	
	
</html>
